<?php
 class Admin_Model_page extends Zend_Db_Table{
	protected $_name='page';
	protected $_primary='pageid';
	public function NewPage($position,$title,$content,$status)
	{
		$row = $this->createRow();
		$row->position = $position;
		$row->title = $title;
		$row->content = $content;
		$row->status=$status;
		$row->save();
		$id = $this->_db->lastInsertId();
		return $id;
	}
	public function getPage($id)
	{
		$select=$this->select()->where('pageid =?',$id);
		$row = $this->fetchRow($select);
		if($row) return $row;
	}
	public function updatePage($id,$title,$position,$content,$status)
	{
		$row = $this->find($id)->current();
		if($row)
		{
			$row->position=$position;
			$row->title=$title;
			$row->content=$content;
			$row->status=$status;
			$row->save();
		}
	}
	public function deletePage($id)
	{
		$row = $this->find($id)->current();
		if($row) $row->delete();
	}
	public function lists()
	{
		$db=Zend_Registry::get('connectDB');
		$sql=$db->select()->from($this->_name);
		
		$result=$db->fetchAll($sql);
		return $result;
	}
}